package controller

import (
	"errors"
	"github.com/gin-gonic/gin"
)

var (
	ControlIns = new()
)

type base struct {
}

func new() *base {
	return &base{}
}

// 获取登录的用户id
func (b *base) UserID(c *gin.Context) int {
	val, _ := c.Get("user_id")
	userId, ok := val.(int)
	if !ok || userId <= 0 {
		panic(errors.New("未登录"))
	}
	return userId
}
